{% extends '::backend.html.twig' %}
{% block contenido %}
{% block documentReadyJavascript %} 
    {{ parent() }}{#este tiene el que oculta los alerts#}
<script type="text/javascript" >      
    $("#buttonFilter").click(function () {
        if ($("#divFilter").css('display') == 'none') {
                $("#divFilter").show("slow");
                $("#icono").attr("class", "icon-minus");
        } else {
            $("#divFilter").hide("slow");
            $("#icono").attr("class", "icon-plus");
        }
    });
    </script>

    <script type="text/javascript" >
       $(".delete").on('click', function(e){
               e.preventDefault()
               $this = $(this);
               $("#confirmation-dialog").dialog({
               resizable: false,
               height:180,
               width:'auto',
               modal: true,
               title:"Alerta!",
               buttons: {
                   "Eliminar": function() {
                       $this.parent().submit();
                   },
                   Cancelar: function() {
                       $( this ).dialog( "close" );
                   }
               }
           });
       });
        </script>

{% endblock documentReadyJavascript %}

     {% include 'BackendBundle:Default:flashAlerts.html.twig'%}

    <a class="btn  btn-success" href="{{ path('cargo_new') }}">
        <i class="icon-plus" ></i>Agregar Cargo
    </a>
    {% if entities %}
    <fieldset>

            <a id="buttonFilter" href="javascript:void(0)"> <legend><i id="icono" class="icon-plus"></i>Filtros</legend></a>
            <div id="divFilter" style="display: none;">
                <form id="search" action="{{ path('cargo')}}" method="POST" >


                    <table class="table table-bordered">
                        <tr>
                            <td>Tipo de Dedicaci&oacute;n</td>
                            <td> {{ form_widget(searchCargo.tipo_de_dedicacion) }}</td>
                        </tr>
                        <tr>
                            <td>Tipo de Cargo</td>
                            <td> {{ form_widget(searchCargo.tipoDeCargo) }}</td>
                        </tr> 
                        <tr>
                            <td>C&aacute;tedra</td>
                            <td> {{ form_widget(searchCargo.catedra) }}</td>
                        </tr>
                    </table>
                    <input class="btn btn-info "  type="submit" value="Filtrar">
                    <a class="btn btn-inverse btn-small" href="{{ path('cargo')}}">Quitar Filtro</a>
                </form>
            </div>
        </fieldset>
    
    <legend>{{title |default('Cargos')}}</legend>

    <table class="table table-striped table-bordered table-striped table-hover">
        <thead>
            <tr>
                <th>Tipo de Cargo</th>
                <th>C&aacute;tedra</th>
                <th>Opciones</th>
            </tr>
        </thead>
        <tbody>
            {% for entity in entities %}
                <tr>
                    <td>{{ entity.tipoDeCargo.nombre }}</td>
                    <td>{{ entity.catedra.nombre }}</td>
                    <td valign="middle" align="center">
                        <a class="btn btn-info  btn-small" href="{{ path('cargo_show', { 'id': entity.id }) }}">
                            <i class=" icon-plus"> </i>  info</i>
                        </a>

                        {% include 'BackendBundle:Default:accionesConPermisos.html.twig' with {'basePath':'cargo','esEditor':true}%}  
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
    <a class="btnOficinaNew" href="{{ path('cargo_new') }}">
    </a>
{% include 'BackendBundle:Default:paginador.html.twig' with { 'ruta': 'cargo' } only %}
{% else %}
    <h3>{{ "No se encontraron cargos" }}</h3>
{% endif %}
{% if (app.session.get('s_isSearch')) %}
            <script type="text/javascript" >
                $("#divFilter").show("slow");
                $("#icono").attr("class", "icon-minus");
                </script>   
{% endif %}
                <div id="confirmation-dialog" style="display:none">
                    <div class="alert alert-error">
                        <strong>Borrara!</strong>  el cargo por completo, est&aacute; seguro?
                    </div>
                </div>

{% endblock %}
